<?php
/* @var $this UserServiceController */
/* @var $model UserService */

$this->breadcrumbs=array(
	Yii::t('base','User Services')=>array('admin'),
	Yii::t('base','Reback'),
);

/*$this->menu=array(
	array('label'=>'List UserService', 'url'=>array('index')),
	array('label'=>'Manage UserService', 'url'=>array('admin')),
);*/
?>

<h1><?php echo Yii::t('base','Reback Equipment')?></h1>
<?php
/* @var $this UserServiceController */
/* @var $model UserService */
/* @var $form CActiveForm */
$user_id = Yii::app()->request->getParam(user_id);
if($user_id!=""){
// 代理人手里有什么设备 直接根据updater从设备表中去查询
$sql="select * from zy_equipment where is_used=1 AND updater=".$user_id;
$connection = yii::app()->db;
$command = $connection->createCommand($sql);
$results = $command->queryAll();
}
?>
<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
		'id'=>'user-service-form',
		'enableAjaxValidation'=>false,
)); ?>

	<p class="note"><?php echo Yii::t('base','Fields with <span class="required">*</span> are required.')?></p>

	<?php echo $form->errorSummary($model); ?>
			<div class="row">
					<input name="access_id" id="access_id" type="hidden" value="<?php echo $user_id;?>" />
			</div>
				<?php if(count($results)>=1){?>
				<div class="row">
					设备:<br/>
					<?php for($i=0;$i<count($results);$i++){ 
						$userservice=UserService::model()->find('equipment_id='.$results[$i]['equipment_id'].' AND isreback=2');
						?>
					<input type="checkbox" checked=true name="equipment[]" value="<?php echo $results[$i]['equipment_id'];?>" /><?php echo $results[$i]['equipment_number'];?>
					<?php  if($userservice->package_id!=0){
						$package=Package::model()->find('package_id='.$userservice->package_id);
						echo '('.$package->package_name.')';
					}?>
					&nbsp;&nbsp;&nbsp;<?php if(($i+1)%6==0&&$i>=2) echo "<br />"; } ?>
				</div>
	<div class="row buttons">
	<?php echo CHtml::submitButton($model->isNewRecord ? Yii::t('base','Reback') : Yii::t('base','Save')); ?>
	<?php } ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->
